package net.moonbiter.ebs;

public class NodeName {
	private boolean singleValue;
	private int index;
	private String nodeName;
	private String linkName;
	
	public NodeName(String nodeName){
		this.nodeName = nodeName;
		if (NamingUtil.isArrayName(nodeName)){
			singleValue = false;
			Object[] arrayInfo = NamingUtil.getArrayInfo(nodeName);
			linkName = (String)arrayInfo[0];
			index = (Integer)arrayInfo[1];
		} else {
			singleValue = true;			
			linkName = nodeName;
			index = -1;
		}
	}

	public boolean isSingleValue() {
		return singleValue;
	}

	public int getIndex() {
		if (isSingleValue()) throw new IllegalArgumentException();
		return index;
	}

	public String getNodeName() {
		return nodeName;
	}

	public String getVariableName() {
		return linkName;
	}
}
